﻿
Imports osi.root.connector
Imports osi.root.formation

Partial Public Class var
    'param array for test only
    Public Sub parse(ByVal ParamArray args() As String)
        raw.clear()
        others.clear()
        Dim name As String = Nothing
        For i As Int32 = 0 To array_size(args) - 1
            If Not String.IsNullOrEmpty(args(i)) Then
                Dim a As String = Nothing
                Dim b As String = Nothing
                If c.is_switcher(args(i), a) Then
                    For j As Int32 = 0 To strlen(a) - 1
                        If raw.find(a(j)) = raw.end() Then
                            raw.insert(a(j), Nothing)
                        End If
                    Next
                ElseIf c.is_full_switcher(args(i), a) Then
                    If raw.find(a) = raw.end() Then
                        raw.insert(a, Nothing)
                    End If
                ElseIf c.is_arg(args(i), a, b) Then
                    If Not raw(a) Is Nothing Then
                        raw(a).push_back(b)
                    End If
                Else
                    others.push_back(args(i))
                End If
            End If
        Next
    End Sub

    Public Sub parse(ByVal i As String)
        If Not String.IsNullOrEmpty(i) Then
            Dim ss() As String = Nothing
            ss = i.Split({c.argument_separator}, StringSplitOptions.RemoveEmptyEntries)
            parse(ss)
        End If
    End Sub
End Class
